<template>
  <div id="app">
    <a-tree-select
      show-search
      style="width: 100%"
      :value="value"
      :dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
      placeholder="Please select"
      allow-clear
      multiple
      tree-default-expand-all
      @change="onChange"
      @search="onSearch"
      @select="onSelect"
    >
      <a-tree-select-node key="0-1" value="parent 1" title="parent 1">
        <a-tree-select-node key="0-1-1" value="parent 1-0" title="parent 1-0">
          <a-tree-select-node key="random" value="leaf1" title="my leaf" />
          <a-tree-select-node key="random1" value="leaf2" title="your leaf" />
        </a-tree-select-node>
        <a-tree-select-node key="random2" value="parent 1-1" title="parent 1-1">
          <a-tree-select-node key="random3" value="sss">
            <b slot="title" style="color: #08c">sss</b>
          </a-tree-select-node>
        </a-tree-select-node>
      </a-tree-select-node>
    </a-tree-select>
  </div>
</template>

<script>
// var touchtime = new Date().getTime();
let count = 0,
  timer,
  num = 2;
export default {
  data() {
    return {
      value: undefined,
    };
  },
  methods: {
    onChange() {
      // if (new Date().getTime() - touchtime < 500) {
      //   console.log("双击dblclick");
      //   this.value = value;
      // } else {
      //   touchtime = new Date().getTime();
      //   console.log("点击click");
      //   return false
      // }

      if (count < num - 1) {
        timer && clearTimeout(timer);
        count++;
        timer = setTimeout(function () {
          count = 0;
          console.log("连续点击了1次");
        }, 300); // 间隔300ms以内才算连续点击
      } else {
        // 5次连击后触发
        count = 0;
        clearTimeout(timer);
        console.log("连续点击了2次");
      }
    },
    onSearch() {
      // console.log(...arguments, 1);
    },
    onSelect() {
      // console.log(...arguments, 2);
    },
  },
};
</script>
<style>
#app {
  width: 300px;
  margin: 0 auto;
}
</style>
